<!-- 失物招领 -->
<template>
  <div class="store">
    <myheader :title="titles" rightBtn="主页" @updataInfo="submitRecruit"></myheader>

    <van-swipe lazy-rende :autoplay="3000">
      <van-swipe-item
        v-for="(items,indexs) in store.imgList "
        :key="indexs"
        @click.stop="bigImg(index,indexs)"
        fit="contain"
      >
        <img :src="items" class="swip_img" />
      </van-swipe-item>
    </van-swipe>

    <van-row v-if="store.length!=0">
      <p
        style="font-size:0.5rem; text-indent: 2em; padding:16px;"
        class="overflowMore"
      >描述：{{store.profile}}</p>
      <p
        style="font-size:0.5rem; text-indent: 2em; padding:16px;"
        class="overflowMore"
      >地址：{{store.address}}</p>
      <p
        style="font-size:0.5rem; text-indent: 2em; padding:16px;"
        class="overflowMore"
      >店铺入驻时间:{{formatDateTime(store.createTime)}}</p>
    </van-row>
    <van-contact-card
      v-if="store.length!=0"
      type="edit"
      :name="name"
      :tel="phone"
      :editable="false"
    />
  </div>
</template>

<script>
import formatDateTime from '../../../utils/data'
import myheader from '../../../comon/myheader.vue'
import { ImagePreview } from 'vant'
export default {
  components: {
    myheader,
  },

  data() {
    return {
      store: [],
      title: '',
      name: '',
      phone: '',
      show: false,
      index: 0,
    }
  },
  created() {
    this.init()
  },

  computed: {
    titles() {
      return '店铺名称:' + this.$route.params.title
    },
  },

  methods: {
    onChange(index) {
      this.show != this.show
    },
    formatDateTime(val) {
      return formatDateTime.formatDateTime5(val)
    },
    async init() {
      const res = await this.$axios.get('/shop/info/' + this.$route.params.id)
      if (res.data.code == 200) {
        this.store = res.data.data
        this.name = res.data.data.user.username
        this.phone = res.data.data.user.phone
        this.title = this.store.title
      }
    },
    bigImg(index, indexs) {
      ImagePreview({
        images: this.store.imgList, // 预览图片的那个数组
        loop: false,
        closeable: true,
        startPosition: indexs, // 指明预览第几张图
      })
      console.log(indexs)
    },
    submitRecruit() {
      this.$router.push('/home')
    },
  },
}
</script>

<style scoped>
.store {
  margin-top: 46px;
}
.van-image {
  width: 86% !important;
  margin-left: 7% !important;
}
.van-cell {
  font-size: 17px !important;
}
.swip_img {
  width: 90%;
}
</style>
